<?php

class loginValidator extends sfValidatorBase
{
 public function configure($options = array(), $messages = array())
  {
    $this->addOption('email_field', 'email');
    $this->addOption('password_field', 'password');
    $this->addOption('throw_global_error', true);

    $this->setMessage('invalid', 'Autentificare esuata!');
  }

  protected function doClean($values)
  {
    $email = isset($values[$this->getOption('email_field')]) ? $values[$this->getOption('email_field')] : '';
    $password = isset($values[$this->getOption('password_field')]) ? $values[$this->getOption('password_field')] : '';
	
		if(!($email && $password))
		{
			return true;
		}
	
    if($email == 'dragosholban@yahoo.com' && $password == 'avioane')
    {
      return $values;
    }
	
    if ($this->getOption('throw_global_error'))
    {
      throw new sfValidatorError($this, 'invalid');
    }

    throw new sfValidatorErrorSchema($this, array(new sfValidatorError($this, 'invalid')));
  }
}